import javax.swing.*;
import java.awt.*;
public class FileOpenCommand extends JMenuItem implements Command {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JFileChooser fileChooser;
    private JPanel panel;
 
    
    public FileOpenCommand(JPanel panel){
        this.panel=panel;
        this.fileChooser=new JFileChooser();
    }
    public void execute(){
        panel.setBackground(Color.WHITE);
        try{
        	String selectedFile = fileChooser.getSelectedFile().toString();
        	if(selectedFile != null){
        		JOptionPane.showMessageDialog(panel,"Ati selectat fisierul urmator: "+selectedFile, "Mesaj", JOptionPane.YES_OPTION);
        	}
        }
        catch(NullPointerException e){
        	JOptionPane.showMessageDialog(panel,"Nu ati selectat niciun fisier","Mesaj", JOptionPane.YES_OPTION);
        }

    }

}
